package com.huang.lock8;

import java.util.concurrent.TimeUnit;

public class test1 {
    public static void main(String[] args) {

        Phone phone=new Phone();
        new Thread(()->{
        phone.sendSms();
        },"Sms").start();

        try {
            TimeUnit.SECONDS.sleep(1);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        new Thread(()->{
            phone.sendEmail();
        },"email").start();
    }

}
class Phone{
    public synchronized void sendSms(){
        try {
            TimeUnit.SECONDS.sleep(2);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("Sms");
    }
    public synchronized void sendEmail(){
        System.out.println("EMAIL");
    }


}
